package dao

import (
	"zk1/gobal"
	"zk1/internal/model"
)

func CreateUser(user *model.Users) bool {
	if err := gobal.DB.Create(&user).Error; err != nil {
		return false
	}
	return true
}
func GetUserMobile(mobile string) model.Users {
	var result model.Users
	err := gobal.DB.Where("mobile = ?", mobile).Find(&result).Error
	if err != nil {
		return model.Users{}
	}
	return result
}

func GetUserMobileAndPassword(mobile string, password string) model.Users {
	var result model.Users
	err := gobal.DB.Where("mobile = ?", mobile).Where("password = ?", password).Find(&result).Error
	if err != nil {
		return model.Users{}
	}
	return result
}

func CreateSay(say *model.Says) bool {
	if err := gobal.DB.Create(&say).Error; err != nil {
		return false
	}
	return true
}
func CreateGift(gift *model.Gifts) bool {
	if err := gobal.DB.Create(&gift).Error; err != nil {
		return false
	}
	return true
}
